package com.tebiecloud.mpweixin.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tebiecloud.mpweixin.client.model.entity.MpminiAccountRef;
import com.tebiecloud.mpweixin.server.mapper.MpminiAccountRefMapper;
import com.tebiecloud.mpweixin.server.service.MpminiAccountRefService;
import com.tebiecloud.common.mybatis.base.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 小程序登录账号关联登录的账号id 服务实现类
 * @author tebie
 * @date 2019-09-24
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class MpminiAccountRefServiceImpl extends BaseServiceImpl<MpminiAccountRefMapper, MpminiAccountRef> implements MpminiAccountRefService {

    @Override
    public MpminiAccountRef getLastMpminiAccountRef(long accountId) {
        QueryWrapper<MpminiAccountRef> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("account_id", accountId);
        queryWrapper.orderByDesc("ct");
        return super.getOne(queryWrapper, false);
    }

}
